home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvi2pcl / openpkfile.c < prev    next >
C/C++ Source or Header  |  1992-11-24  |  3KB  |  92 lines

  1. /* $Log:    openpkfile.c,v $
  2.  * Revision 0.8  92/11/23  19:46:50  19:46:50  bt (Bo Thide')
  3.  * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
  4.  * 
  5.  * Revision 0.7  92/11/13  02:41:35  02:41:35  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:47:51  21:47:51  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:38  16:25:38  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:54  02:45:54  bt (Bo Thide')
  15.  * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
  16.  * 
  17.  * Revision 0.3  92/08/24  12:45:45  12:45:45  bt (Bo Thide')
  18.  * Fixed 8 bit (dc font) support.
  19.  * 
  20.  * Revision 0.2  92/08/23  17:28:58  17:28:58  bt (Bo Thide')
  21.  * Source cleaned up.  Changed certain function calls.  Removed globals.
  22.  * 
  23.  * Revision 0.1  92/08/22  23:58:48  23:58:48  bt (Bo Thide')
  24.  * First Release.
  25.  *  */
  26.  
  27. #include <stdio.h>
  28. #include <string.h>
  29. #include "globals.h"
  30. #include "paths.h"
  31.  
  32. static char rcsid[] = "$Header: openpkfile.c,v 0.8 92/11/23 19:46:50 bt Exp $";
  33.  
  34. FILE *openpkfile()
  35.     FILE    *fileptr;
  36.     char    *fptr, *nptr, *pptr;
  37.     char    *pt_chrs = "0123456789", *pt_ptr;
  38.     int    pt_value;
  39.  
  40.     nptr = &names[font->name];
  41.     fptr = pkname;
  42.     pptr = fontpath;
  43.  
  44.     if(*nptr)
  45.         while(*nptr)
  46.             *fptr++ = *nptr++;
  47.     else
  48.         while(*pptr)
  49.             *fptr++ = *pptr++;
  50.     nptr++;
  51.  
  52.     /* Find the pt size from the font name string */
  53.     pt_ptr = strpbrk(nptr, pt_chrs);
  54.     sscanf(pt_ptr, "%d", &pt_value);
  55.  
  56.     /* Look for the pk fonts in pk300/10pt/cmr10.300pk etc.*/
  57.     sprintf(fptr,"/%dpt/%s.%dpk", pt_value, nptr, font->dir_size);
  58.  
  59.     /* Try to open pk font file */
  60.     if((fileptr = fopen(pkname,"r")) != NULL)
  61.       return fileptr;
  62.  
  63.     /* Look for the pk fonts in pk300/cmr10.300pk etc.*/
  64.     sprintf(fptr,"/%s.%dpk", nptr, font->dir_size);
  65.     if((fileptr = fopen(pkname,"r")) != NULL)
  66.       return fileptr;
  67.  
  68.     fprintf(stderr,"Cannot find pk font file %s\n",pkname);
  69.  
  70.     /* Try to substitute at base resolution */
  71.     font->dir_size = pt_value = RESOLUTION;
  72.  
  73.     sprintf(fptr, "/%dpt/%s.%dpk", pt_value,nptr, font->dir_size);
  74.     if((fileptr = fopen(pkname,"r")) != NULL){
  75.         fprintf(stderr,"Substituting %s at %d points\n", nptr,pt_value);
  76.         return fileptr;
  77.     }
  78.  
  79.     sprintf(fptr, "/%s.%dpk",nptr,font->dir_size);
  80.     if((fileptr = fopen(pkname,"r")) != NULL){
  81.         fprintf(stderr,"Substituting %s at %d points\n", nptr,pt_value);
  82.         return fileptr;
  83.     }
  84.  
  85.     fprintf(stderr,"Substituting cmr10 at ten points . . .\n");
  86.     if ((fileptr = fopen(defaultpk,"r")) != NULL)
  87.         return 0;
  88.     fprintf(stderr, "Killed in openpkfile()\n");
  89.     exit(-1);
  90. }
  91.